home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8614 / 8614.xpi / modules / application / Feedback.jsm < prev    next >
Text File  |  2010-02-10  |  2KB  |  71 lines

  1. // DO NOT import this into the global namespace, but instead
  2. // import it into your own namespace wrapper
  3.  
  4. var EXPORTED_SYMBOLS = ["Feedback"];
  5.  
  6. Components.utils.import("resource://glydo/utils/prototype_xul_1_6_0_3_modified.jsm");
  7. Components.utils.import("resource://glydo/utils/Prefs.jsm");
  8. Components.utils.import("resource://glydo/ClientInfo.jsm");
  9.  
  10. var Feedback = Prototype.Class.create({
  11.     initialize: function(rec) {
  12.         this.rec = rec;
  13.     },
  14.  
  15.     send: function() {
  16.         var server_url = Prefs.server_url;
  17.         if (!server_url) {
  18.             return;
  19.         }
  20.         var params = {
  21.                 action: "feedback",
  22.                 clientId: CLIENT_INFO.clientId,
  23.                 rec_set_id: this.rec.recSetId,
  24.                 rec_id: this.rec.id,
  25.         };
  26.         if (Prefs.server_trace) {
  27.             params.useTrace = 1;
  28.         }
  29.         if (this.rec.feedback_details !== undefined && this.rec.feedback_details !== null) {
  30.             for (var d in this.rec.feedback_details) {
  31.                 params["feedback_"+d] = this.rec.feedback_details[d];
  32.             }
  33.         }
  34.         if (this.rec.feedback_comment !== undefined && this.rec.feedback_comment !== null) {
  35.             params.feedback_comment = this.rec.feedback_comment;
  36.         }
  37.     
  38.         // Create a new AJAX request for the feedback
  39.         var ajax_request = new Prototype.Ajax.Request(
  40.                 server_url, {
  41.                     method: 'post',
  42.                     parameters: params,
  43.                     onSuccess: Prototype.F.bind(this.onSendSuccess,this),
  44.                     onFailure: Prototype.F.bind(this.onSendFailure,this)
  45.                 });
  46.         
  47.     },
  48.     
  49.     onSendSuccess: function(response) {
  50.         if (!response || (response.status === 0)) {
  51.             this.onSendFailure(response);
  52.             return;
  53.         }
  54.         if ((response.status !== 200) || (response.responseText !== "")) {
  55.             
  56.             
  57.             
  58.             return;
  59.         }
  60.         
  61.     },
  62.     
  63.     onSendFailure: function(response) {
  64.         var error = response ? response.responseText : "Communication problem";
  65.         if (!error) {
  66.             error = "Communication problem";
  67.         }
  68.         
  69.     }
  70. });
  71.